package com.hospital.hospital.service.impl;

import com.hospital.hospital.bean.Manager;
import com.hospital.hospital.mapper.ManagerMapper;
import com.hospital.hospital.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author xfm
 * @create 2021/9/3
 */
@Service
public class ManagerServiceImpl implements ManagerService {
    @Autowired
    private ManagerMapper managerMapper;
    @Override
    public void regist(Manager manager) throws Exception {
        Manager manager1 = managerMapper.queryByName(manager.getMname());
        if(manager1!=null){
            throw new Exception("用户已存在");
        }else {
            managerMapper.insert(manager);
        }
    }

    @Override
    public Manager login(String mname) throws Exception {
        Manager manager = managerMapper.queryByName(mname);
        if(manager==null){
            throw new Exception("用户不存在");
        }else {
        return manager;}
    }
}
